package com.cssw.fyzb.busi.service.system;

import com.cssw.fyzb.core.dao.system.AppVersionDao;
import com.cssw.fyzb.core.model.dodb.AppVersion;
import com.ydn.dbframe.plugin.activerecord.Db;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author zhouxu
 * @create 2020-08-25 17:30
 */
@Service
public class AppVersionServiceImpl implements AppVersionService {

    @Autowired
    private AppVersionDao appVersionDao;

    @Override
    public AppVersion getVersion(String appName, String type) {
        return appVersionDao.getVersion(appName, type);
    }

    @Override
    public void updateAppVersion(
            String name, String appName, String appUrl1, String appUrl2,
            String versionName, String versionCode, String content, String type, String forceUpdate
    ) {
        Db.tx(() -> {
            appVersionDao.updateVersionOFF(appName, type);
            appVersionDao.updateAppVersion(
                    name, appName, appUrl1, appUrl2, versionName,
                    versionCode, content, type, forceUpdate
            );
            return true;
        });

    }
}
